package com.br.rh.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.br.rh.vo.PlanoCargo;
import java.sql.PreparedStatement;

public class PlanoCargoDAO extends DataUtils {
	public List<PlanoCargo> getAll(){
		PreparedStatement stmt = null;
		Connection conn = null;
		List<PlanoCargo> lista = new ArrayList<PlanoCargo>();
		ResultSet rs = null;
		PlanoCargo planoCargo = null;
		
		try {
			conn = getConnection();
			stmt = (PreparedStatement) conn.prepareStatement("SELECT * FROM plano_cargo;");
			rs = stmt.executeQuery();
			while(rs.next()){
				planoCargo = new PlanoCargo();
				planoCargo.setCodigo(rs.getInt(1));
				planoCargo.setPlanoCargoSalario(rs.getString(2));
				planoCargo.setOcupacao(rs.getString(3));
				lista.add(planoCargo);
			}
			conn.close();
			stmt.close();
			rs.close();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return lista;
		
	}
	public static void main(String[] args) {
		System.out.println(new PlanoCargoDAO().getAll().toString());
		
	}
}

